package com.gree.common.utils;

import java.sql.*;

public class JDBCUtil {

    public static final String DRIVER = "oracle.jdbc.OracleDriver";

    public static Connection getConnection(String url,String username,String password){
        Connection con = null;
        try{
            Class.forName(DRIVER);
            con = DriverManager.getConnection(url, username, password);
        }catch (ClassNotFoundException | SQLException e){
            e.printStackTrace();
        }
        return con;
    }

    public static void close(ResultSet rs,PreparedStatement ps,Connection con) {
        if(rs != null){
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(ps != null){
            try {
                ps.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(con != null){
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
